import os
import platform
import sys
from pandas.core.frame import DataFrame
import pandas as pd


# 9合并函数
def clean_merge(input_file_1, input_file_2, merge_type):
    """

    :param input_file_1: 输入第一个文件地址
    :param input_file_2: 输入第二个文件地址
    :param merge_type: 合并类型0: inner, 1: left, 2: right, 3: outer
    :return: 数组格式输出数据
    """
    merge_type = int(merge_type)
    dict_type = {0: "inner", 1: "left", 2: "right", 3: "outer"}
    with open(input_file_1) as file_obj_1:
        with open(input_file_2) as file_obj_2:
            array_1 = eval(file_obj_1.read())
            array_2 = eval(file_obj_2.read())
            df1 = DataFrame(array_1)
            df2 = DataFrame(array_2)
            df3 = pd.merge(df1, df2, how=dict_type[merge_type])
            after = df3[0].tolist()

            return after


if __name__ == '__main__':
    print(clean_merge(sys.argv[1], sys.argv[2], sys.argv[3]))
